package com.college.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.college.bean.User;
import com.college.db.connection.DBConnecton;
import com.college.facade.RegistrationFacade;

public class UserRegistrationServlet extends HttpServlet{

	/**
	 * 
	 */
	
	public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
	{
		
		User user = new User();
		user.setUserName(request.getParameter("userName"));
		user.setPassword(request.getParameter("password"));
		user.setAddress(request.getParameter("address"));
		user.setDob(request.getParameter("dob"));
		user.setContactNo(request.getParameter("mobile"));
		
		RegistrationFacade registrationFacade=new RegistrationFacade();
		
		try {
			if(registrationFacade.registrationFacade(user)){
				response.sendRedirect("login.jsp");
			}
			else{
				response.sendRedirect("newuser.jsp");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

	}
	
}
